package org.lxw.stock;

import java.util.Date;

import com.sleepycat.persist.model.Entity;
import com.sleepycat.persist.model.KeyField;
import com.sleepycat.persist.model.Persistent;
import com.sleepycat.persist.model.PrimaryKey;

@Entity
public class LC5Data {
	@PrimaryKey
	Key key;
	float open;
	float low;
	float high;
	float close;
	float turnover;
	int volume;

	private LC5Data() {
	}

	public LC5Data(String stock, long date, float open, float low, float high,
			float close, float turnover, int volume) {
		key = new Key(stock, date);
		this.open = open;
		this.low = low;
		this.high = high;
		this.close = close;
		this.turnover = turnover;
		this.volume = volume;
	}

	public Key getKey() {
		return key;
	}

	public void setKey(Key key) {
		this.key = key;
	}

	public float getOpen() {
		return open;
	}

	public void setOpen(float open) {
		this.open = open;
	}

	public float getLow() {
		return low;
	}

	public void setLow(float low) {
		this.low = low;
	}

	public float getHigh() {
		return high;
	}

	public void setHigh(float high) {
		this.high = high;
	}

	public float getClose() {
		return close;
	}

	public void setClose(float close) {
		this.close = close;
	}

	public float getTurnover() {
		return turnover;
	}

	public void setTurnover(float turnover) {
		this.turnover = turnover;
	}

	public int getVolume() {
		return volume;
	}

	public void setVolume(int volume) {
		this.volume = volume;
	}

	@Override
	public String toString() {
		return new Date(key.date).toLocaleString() + "," + getOpen() + ","
				+ getLow() + "," + getHigh() + "," + getClose() + ","
				+ getTurnover() + "," + getVolume();
	}

	@Persistent
	static class Key  {
		@KeyField(1)
		String stock;
		@KeyField(2)
		long date;

		private Key() {
		}

		public Key(String stock, long date) {
			this.date = date;
			this.stock = stock;
		}
	}
}
